﻿namespace HRM.CORE
{
    using DevExpress.Utils;
    using DevExpress.XtraBars;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using APP.HELPER;
    using HRM.CORE;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms; using Common;

    public class xucMinimumSalary : Common.xucBase
    {
        private BarDockControl barDockControlBottom;
        private BarDockControl barDockControlLeft;
        private BarDockControl barDockControlRight;
        private BarDockControl barDockControlTop;
        private BarManager barManager1;
        private BarButtonItem bbiDelete;
        private BarButtonItem bbiEdit;
        private BarButtonItem bbiSave;
        private CalcEdit calMoney;
        private IContainer components = null;
        private DateEdit dtDate;
        private GroupBox groupBox2;
        private DevExpress.Utils.ImageCollection imageCollection1;
        private LabelControl labelControl1;
        private LabelControl labelControl7;
        private LabelControl lcDate;
        private LabelControl lcDecideNumber;
        private LabelControl lcFilePath;
        private LabelControl lcMoney;
        private LabelControl lcPerson;
        private PopupMenu ppMenu;
        private TextEdit txtDecideNumber;
        private ButtonEdit txtFilePath;
        private TextEdit txtPerson;
        private XtraScrollableControl xtraScrollableControl1;

        public xucMinimumSalary()
        {
            this.InitializeComponent();
            this.Init();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Init()
        {
            DIC_MINIMUMSALARY dic_minimumsalary = new DIC_MINIMUMSALARY();
            dic_minimumsalary.Get();
            this.calMoney.EditValue = dic_minimumsalary.Money;
            this.dtDate.DateTime = dic_minimumsalary.Date;
            this.txtDecideNumber.Text = dic_minimumsalary.DecideNumber;
            this.txtFilePath.Text = dic_minimumsalary.FilePath;
            this.txtPerson.Text = dic_minimumsalary.Person;
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xucMinimumSalary));
            SerializableAppearanceObject appearance = new SerializableAppearanceObject();
            this.xtraScrollableControl1 = new XtraScrollableControl();
            this.labelControl7 = new LabelControl();
            this.groupBox2 = new GroupBox();
            this.txtFilePath = new ButtonEdit();
            this.lcFilePath = new LabelControl();
            this.lcMoney = new LabelControl();
            this.lcDecideNumber = new LabelControl();
            this.lcDate = new LabelControl();
            this.txtDecideNumber = new TextEdit();
            this.barManager1 = new BarManager(this.components);
            this.barDockControlTop = new BarDockControl();
            this.barDockControlBottom = new BarDockControl();
            this.barDockControlLeft = new BarDockControl();
            this.barDockControlRight = new BarDockControl();
            this.imageCollection1 = new DevExpress.Utils.ImageCollection(this.components);
            this.bbiSave = new BarButtonItem();
            this.bbiEdit = new BarButtonItem();
            this.bbiDelete = new BarButtonItem();
            this.dtDate = new DateEdit();
            this.txtPerson = new TextEdit();
            this.calMoney = new CalcEdit();
            this.lcPerson = new LabelControl();
            this.ppMenu = new PopupMenu(this.components);
            this.labelControl1 = new LabelControl();
            this.xtraScrollableControl1.SuspendLayout();
            this.txtFilePath.Properties.BeginInit();
            this.txtDecideNumber.Properties.BeginInit();
            this.barManager1.BeginInit();
            this.imageCollection1.BeginInit();
            this.dtDate.Properties.VistaTimeProperties.BeginInit();
            this.dtDate.Properties.BeginInit();
            this.txtPerson.Properties.BeginInit();
            this.calMoney.Properties.BeginInit();
            this.ppMenu.BeginInit();
            base.SuspendLayout();
            this.xtraScrollableControl1.Controls.Add(this.labelControl1);
            this.xtraScrollableControl1.Controls.Add(this.labelControl7);
            this.xtraScrollableControl1.Controls.Add(this.groupBox2);
            this.xtraScrollableControl1.Controls.Add(this.txtFilePath);
            this.xtraScrollableControl1.Controls.Add(this.lcFilePath);
            this.xtraScrollableControl1.Controls.Add(this.lcMoney);
            this.xtraScrollableControl1.Controls.Add(this.lcDecideNumber);
            this.xtraScrollableControl1.Controls.Add(this.lcDate);
            this.xtraScrollableControl1.Controls.Add(this.txtDecideNumber);
            this.xtraScrollableControl1.Controls.Add(this.dtDate);
            this.xtraScrollableControl1.Controls.Add(this.txtPerson);
            this.xtraScrollableControl1.Controls.Add(this.calMoney);
            this.xtraScrollableControl1.Controls.Add(this.lcPerson);
            this.xtraScrollableControl1.Dock = DockStyle.Fill;
            this.xtraScrollableControl1.Location = new Point(0, 0);
            this.xtraScrollableControl1.Name = "xtraScrollableControl1";
            this.xtraScrollableControl1.Size = new Size(0x1fa, 0x11e);
            this.xtraScrollableControl1.TabIndex = 0;
            this.labelControl7.AllowHtmlString = true;
            this.labelControl7.AutoSizeMode = LabelAutoSizeMode.None;
            this.labelControl7.Location = new Point(0x12, 0x27);
            this.labelControl7.Name = "labelControl7";
            this.labelControl7.Size = new Size(0x1d7, 0x24);
            this.labelControl7.TabIndex = 0x22;
            this.labelControl7.Text = "Mức lương tối thiểu n\x00e0y được \x00e1p dụng cho to\x00e0n bộ c\x00f4ng ty - l\x00e0 mức lương thấp nhất v\x00e0 lớn hơn mức lương tối thiểu do nh\x00e0 nước quy định tại thời điểm hiện tại.";
            this.groupBox2.Font = new Font("Tahoma", 9.75f, FontStyle.Bold);
            this.groupBox2.ForeColor = Color.Blue;
            this.groupBox2.Location = new Point(0x12, 15);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new Size(0x1d8, 0x12);
            this.groupBox2.TabIndex = 0x21;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "Mức lương tối thiểu";
            this.txtFilePath.Location = new Point(0x60, 0x98);
            this.txtFilePath.Name = "txtFilePath";
            //this.txtFilePath.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Glyph, "", -1, true, true, false, ImageLocation.MiddleCenter, (Image) manager.GetObject("txtFilePath.Properties.Buttons"), new KeyShortcut(Keys.None), appearance, "", "Browse", null, true) });
            this.txtFilePath.Properties.ButtonClick += new ButtonPressedEventHandler(this.txtFilePath_Properties_ButtonClick);
            this.txtFilePath.Size = new Size(0x189, 0x16);
            this.txtFilePath.TabIndex = 0x20;
            this.txtFilePath.ButtonClick += new ButtonPressedEventHandler(this.txtFilePath_Properties_ButtonClick);
            this.lcFilePath.Location = new Point(0x12, 0x9c);
            this.lcFilePath.Name = "lcFilePath";
            this.lcFilePath.Size = new Size(0x4a, 13);
            this.lcFilePath.TabIndex = 0x1f;
            this.lcFilePath.Text = "File quyết định:";
            this.lcMoney.AllowHtmlString = true;
            this.lcMoney.Location = new Point(20, 0x5d);
            this.lcMoney.Name = "lcMoney";
            this.lcMoney.Size = new Size(0x36, 14);
            this.lcMoney.TabIndex = 0x17;
            this.lcMoney.Text = "Số tiền <color=red>(*)</color>:";
            this.lcDecideNumber.Location = new Point(0x13, 0x7d);
            this.lcDecideNumber.Name = "lcDecideNumber";
            this.lcDecideNumber.Size = new Size(70, 13);
            this.lcDecideNumber.TabIndex = 0x1b;
            this.lcDecideNumber.Text = "Số quyết định:";
            this.lcDate.Location = new Point(0x11b, 0x5d);
            this.lcDate.Name = "lcDate";
            this.lcDate.Size = new Size(0x55, 13);
            this.lcDate.TabIndex = 0x19;
            this.lcDate.Text = "\x00c1p dụng từ ng\x00e0y:";
            this.txtDecideNumber.Location = new Point(0x60, 0x7a);
            this.txtDecideNumber.MenuManager = this.barManager1;
            this.txtDecideNumber.Name = "txtDecideNumber";
            this.txtDecideNumber.Size = new Size(0x74, 20);
            this.txtDecideNumber.TabIndex = 0x1c;
            this.barManager1.DockControls.Add(this.barDockControlTop);
            this.barManager1.DockControls.Add(this.barDockControlBottom);
            this.barManager1.DockControls.Add(this.barDockControlLeft);
            this.barManager1.DockControls.Add(this.barDockControlRight);
            this.barManager1.Form = this;
            this.barManager1.Images = this.imageCollection1;
            this.barManager1.Items.AddRange(new BarItem[] { this.bbiSave, this.bbiEdit, this.bbiDelete });
            this.barManager1.MaxItemId = 3;
           // this.imageCollection1.ImageStream = (ImageCollectionStreamer) manager.GetObject("imageCollection1.ImageStream");
            this.imageCollection1.Images.SetKeyName(0, "open-16x16.png");
            this.imageCollection1.Images.SetKeyName(1, "print-16x16.png");
            this.imageCollection1.Images.SetKeyName(2, "save-16x16.png");
            this.imageCollection1.Images.SetKeyName(3, "MenuBar_Delete.png");
            this.imageCollection1.Images.SetKeyName(4, "new16.png");
            this.imageCollection1.Images.SetKeyName(5, "application_view_detail.png");
            this.bbiSave.Caption = "\x00c1p Dụng";
            this.bbiSave.Id = 0;
            this.bbiSave.ImageIndex = 2;
            this.bbiSave.Name = "bbiSave";
            this.bbiEdit.Caption = "Thay Đổi";
            this.bbiEdit.Id = 1;
            this.bbiEdit.ImageIndex = 5;
            this.bbiEdit.Name = "bbiEdit";
            this.bbiDelete.Caption = "X\x00f3a";
            this.bbiDelete.Id = 2;
            this.bbiDelete.ImageIndex = 3;
            this.bbiDelete.Name = "bbiDelete";
            this.dtDate.EditValue = new DateTime(0x7db, 10, 13, 10, 0x19, 0x26, 0);
            this.dtDate.Location = new Point(0x176, 90);
            this.dtDate.MenuManager = this.barManager1;
            this.dtDate.Name = "dtDate";
            this.dtDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.dtDate.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.dtDate.Size = new Size(0x73, 20);
            this.dtDate.TabIndex = 0x1a;
            this.txtPerson.Location = new Point(0x176, 0x7a);
            this.txtPerson.MenuManager = this.barManager1;
            this.txtPerson.Name = "txtPerson";
            this.txtPerson.Size = new Size(0x74, 20);
            this.txtPerson.TabIndex = 30;
            int[] bits = new int[4];
            this.calMoney.EditValue = new decimal(bits);
            this.calMoney.Location = new Point(0x60, 90);
            this.calMoney.MenuManager = this.barManager1;
            this.calMoney.Name = "calMoney";
            this.calMoney.Properties.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.calMoney.Properties.Appearance.Options.UseFont = true;
            this.calMoney.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calMoney.Properties.DisplayFormat.FormatString = "{0} VND";
            this.calMoney.Properties.DisplayFormat.FormatType = FormatType.Numeric;
            this.calMoney.Properties.EditFormat.FormatString = "{0} VND";
            this.calMoney.Properties.EditFormat.FormatType = FormatType.Numeric;
            this.calMoney.Properties.Mask.UseMaskAsDisplayFormat = true;
            this.calMoney.Size = new Size(0x74, 20);
            this.calMoney.TabIndex = 0x18;
            this.lcPerson.Location = new Point(0x10d, 0x7d);
            this.lcPerson.Name = "lcPerson";
            this.lcPerson.Size = new Size(0x63, 13);
            this.lcPerson.TabIndex = 0x1d;
            this.lcPerson.Text = "Người ra quyết định:";
            this.ppMenu.LinksPersistInfo.AddRange(new LinkPersistInfo[] { new LinkPersistInfo(this.bbiDelete), new LinkPersistInfo(this.bbiDelete) });
            this.ppMenu.Manager = this.barManager1;
            this.ppMenu.Name = "ppMenu";
            this.labelControl1.AllowHtmlString = true;
            this.labelControl1.AutoSizeMode = LabelAutoSizeMode.None;
            this.labelControl1.Location = new Point(0x12, 0xc2);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(0x1d7, 0x24);
            this.labelControl1.TabIndex = 0x23;
            this.labelControl1.Text = "<b><i>Lưu \x00fd:</i> Thiết lập mức lương tối thiểu theo v\x00f9ng trong th\x00f4ng tin chi nh\x00e1nh.</b>";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
//            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.xtraScrollableControl1);
            base.Controls.Add(this.barDockControlLeft);
            base.Controls.Add(this.barDockControlRight);
            base.Controls.Add(this.barDockControlBottom);
            base.Controls.Add(this.barDockControlTop);
            base.Name = "xucMinimumSalary";
            base.Size = new Size(0x1fa, 0x11e);
            this.xtraScrollableControl1.ResumeLayout(false);
            this.xtraScrollableControl1.PerformLayout();
            this.txtFilePath.Properties.EndInit();
            this.txtDecideNumber.Properties.EndInit();
            this.barManager1.EndInit();
            this.imageCollection1.EndInit();
            this.dtDate.Properties.VistaTimeProperties.EndInit();
            this.dtDate.Properties.EndInit();
            this.txtPerson.Properties.EndInit();
            this.calMoney.Properties.EndInit();
            this.ppMenu.EndInit();
            base.ResumeLayout(false);
        }

        public void Save()
        {
            SYS_LOG.Insert("Mức Lương Tối Thiểu", "Sửa", this.calMoney.EditValue.ToString());
            string text = new DIC_MINIMUMSALARY().Update(Guid.NewGuid(), decimal.Parse(this.calMoney.EditValue.ToString()), this.dtDate.DateTime, this.txtDecideNumber.Text, this.txtPerson.Text, this.txtFilePath.Text, true);
            if (text != "OK")
            {
                XtraMessageBox.Show(text, "Cảnh B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }

        private void txtFilePath_Properties_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog {
                Filter = "All File(*.*)|*.*",
                FilterIndex = 0
            };
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                this.txtFilePath.Text = dialog.FileName;
            }
        }
    }
}

